<link rel="stylesheet" href="<?php echo URL::base() ?>media/vendor/css/style.css" type="text/css" media="all" />
<link rel="stylesheet" href="<?php echo URL::base() ?>media/vendor/artdialog/skins/default.css" type="text/css" media="all" />
<link href="<?php echo URL::base() ?>media/vendor/css/ui-lightness/jquery-ui-1.10.4.custom.css" rel="stylesheet">
<!--<link href="--><?php //echo URL::base() ?><!--media/vendor/fixtable/css/component.css" rel="stylesheet">-->
<!--<link href="--><?php //echo URL::base() ?><!--media/vendor/fixtable/css/normalize.css" rel="stylesheet">-->
<link href="<?php echo URL::base() ?>media/vendor/css/jquery-ui-timepicker-addon.min.css" rel="stylesheet">
<script src="<?php echo URL::base() ?>media/vendor/js/jquery-1.10.2.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery-ui-1.10.4.custom.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery-ui-timepicker-addon.min.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery-ui-timepicker-zh-CN.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery.ui.datepicker-zh-TW.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/Validform_v5.3.2_ncr_min.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/artdialog/jquery.artDialog.js"></script>	   
<script src="<?php echo URL::base() ?>media/vendor/js/jquery.printPage.js"></script>
<script type="text/javascript">
$(function() {
    //$( document ).tooltip({ hide: { effect: "explode", duration: 1000 } });
    $('#inventory_time').datetimepicker({
        dateFormat: 'yy-mm-dd',
        timeFormat: 'HH:mm:ss',
        maxDate: new Date()}
    );
	$(".supplierform").Validform({
        tiptype:2,
        ajaxPost:true,
        callback:function(data){
                setTimeout(function(){
                    $.Hidemsg(); //公用方法关闭信息提示框;显示方法是$.Showmsg("message goes here.");
                },3000);
                if(data.status=='y'){
                    $('.supplierform')[0].reset();
                    var url="<?php echo URL::base() ?>inventory/Reportprint?id="+data.id;
                    //$('.btnPrint').show().attr('href',url);
                }
        }
    });
    $('select[name=warehouseid]').change(function () {
        var ware_id = $(this).find('option:selected').val();
        $('select[name=enterprise_dominant] option:not([value=0])').remove();
        if(typeof(warehouses[ware_id]) == 'undefined') {
            $('td.warehouse').text('');
            return ;
        }
        var warehouse = warehouses[ware_id];
        if(typeof(warehouse.enterprise_dominant) != 'object') {
            alert('请联系管理员正确配置仓库主体信息');
            return ;
        }
        for(var i in warehouse.enterprise_dominant) {
            var enterprise = warehouse.enterprise_dominant[i];
            $('<option value="'+enterprise.id+'">'+enterprise.name+'</option>').appendTo('select[name=enterprise_dominant]');
        }
    });
    $("input[name='sku']").blur(function(){
    	$.get(
    	    "<?php echo URL::base() ?>inventory/deliverycheck/load_sku_info",
    	    {sku: $(this).val(), warehouseid : $("#warehouseid").val()},
	    	function(data){
    	    	data=JSON.parse(data);
    	    	if(data.status=='y')
    	    	{ 
        	    	 $("input[name='sku_name']").val(data.info['products_name_cn']);
        	    	 $("input[name='sku_standard']").val(data.info['size']);
        	    	 $("input[name='storage_position']").val(data.info['products_place']);
    	    	}
    	    	else
    	    	{
    	    		 $("input[name='sku_name']").val('未找到对应信息');
        	    	 $("input[name='sku_standard']").val('未找到对应信息');
        	    	 $("input[name='storage_position']").val('未找到对应信息');
    	    	}
	   	   }
    	 );
    	});
	//打印
    $(".btnPrint").myprint();
	//上传表格
    $(".upSuppForm").Validform({
        tiptype:2});
     });
</script>
<!-- 将结果展示在这里 -->

<!-- 结果展示结束 -->

<form class="supplierform" method="post" action="<?php  echo URL::base() ?>inventory/delivery/special">
    <table style="width:700px;" class="table">
    <tr>
        <td width="30">*</td>
        <td width="120">选择仓库：</td>
        <td>
            <select id='warehouseid' name='warehouseid'>
                <option value="0">--请选择--</option>
                <?php foreach ($warehouse as $var) { ?>
                    <option value="<?php echo $var['id'] ?>"><?php echo $var['name'] ?></option>
                <?php } ?>
            </select>
        </td>
        <td width="160"></td>
    </tr>
    <tr>
        <td width="30">*</td>
        <td width="120">选择主体：</td>
        <td>
            <select id='enterprise_dominant' name='enterprise_dominant'>
                <option value="0">--请选择--</option>
                <?php /*foreach ($enterprise_dominants as $id => $name) { */?><!--
                    <option value="<?php /*echo $id */?>"><?php /*echo $name */?></option>
                --><?php /*} */?>
            </select>
        </td>
        <td></td>
    </tr>
    <tr>
        <td class="need">*</td>
        <td>出库类型：</td>
        <td>
        <select name="type" datatype="*" >
        <?php if(count($status)>0){foreach ($status as $s):?>
          <option value="<?php echo $s['number']?>"><?php echo $s['value'] ?></option>
        <?php endforeach;}?>
         </select>
            </td>
        <td><div class="Validform_checktip"></div></td>
    </tr>
    <tr>
        <td>*</td>
        <td > SKU：</td>
        <td><input type="text" value=""  name="sku" class="inputxt" datatype="*"
                   ajaxurl="<?php echo URL::site() ?>inventory/deliverycheck/checksku"
                   sucmsg="SKU验证通过"  errormsg="输入的SKU有误" /></td>
        <td><div class="Validform_checktip"></div></td>
    </tr>
    <tr>
        <td>*</td>
        <td > 中文名称：</td>
        <td><input type="text" value=""   name="sku_name" class="inputxt"  datatype="*"   readonly = "readonly" /></td>
        <td><div class="Validform_checktip"></div></td>
    </tr>
     <tr>
        <td></td>
        <td > 规格：</td>
        <td><input type="text" value=""   name="sku_standard" class="inputxt"/></td>
        <td></td>
    </tr>
      <tr>
        <td>*</td>
        <td > 储位：</td>
        <td><input type="text" value=""   name="storage_position" class="inputxt" /></td>
        <td></td>
    </tr>
     <!--<tr>
        <td class="need">*</td>
        <td > 出库时间：</td>
        <td ><input type="text"  name="delivery_date" class="inputxt"  id='inventory_time'
                    datatype="*" readonly="readonly"  value="<?php /*echo date('Y-m-d H:i:s')*/?>"/></td>
        <td><div class="Validform_checktip"></div></td>
    </tr>-->
      <tr>
        <td>*</td>
        <td> 数量：</td>
        <td><input type="text" value=""   name="quantity" class="inputxt"
                   datatype="/^[1-9](\d+)?$/" errormsg="数量只能为正整数"  /></td>
        <td><div class="Validform_checktip"></div></td>
    </tr>
    <tr>
        <td class="need"></td>
        <td > 备注：</td>
        <td ><input type="text" value=""   name="remark" class="inputxt"    /></td>
        <td><div class="Validform_checktip"></div></td>
    </tr>
    <tr>
        <td class="need"></td>
        <td></td>
        <td colspan="2">
            <input type="submit" value="提 交" class="btn btn-info"/>&nbsp;&nbsp;&nbsp;
            <input type="reset" value="重 置" class='btn' />
        </td>
    </tr>
</table>
</form>


<a class="btnPrint btn  btn-danger" style="display:none ">打印</a>
<?php
echo '<script>var warehouses = ' . json_encode($warehouse) . ';</script>';
?>
<!--<div class="">
  <div class="">
  <h2>出库批量上传数据：<lable style="color: #ff0000">1库存盘点请到 库存查询--><!--盘点库存（新）</lable></h2>-->
  <!--<form class="upSuppForm" method='post' action='< ?php /*/*echo URL::site() */*/?>inventory/delivery/upload_delivery' enctype="multipart/form-data">
  <table class="table ">
      <tr>
          <td class="need"></td>
          <td>批量上传</td>
          <td><input type='file' style="line-height: 0px;" name='xls' class="inputxt" datatype="/.+\.xls/"  nullmsg="请选择上传文件"
                    errormsg="文件格式只能为xls"/></td>
          <td><div class="Validform_checktip"></div></td>
      </tr>
      <tr>
          <td class="need"></td>
          <td></td>
          <td colspan="2"></td>
      </tr>
  </table>
      <input type='submit' value='上传' class='btn btn-success' />
      <div class="btn btn-success">
          <a href="< ?php /*/*echo URL::site() */*/?>inventory/delivery/down_template" style="color: #ffffff">下载模版
          </a>
      </div>
  </form>
  
  </div>
</div>-->
